<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .box {
            width: 1000px;
            height: 500px;
            margin: auto;
            outline: 2px solid red;
            list-style: none;
            display: flex;
        }

        .box li {
            width: 70px;
            height: 500px;
            overflow: hidden;
        }

        .box li img {
            width: 1000px;
            height: 500px;
        }

        .active {
            flex-grow: 1;
            /* 占满父元素剩下的空间 */
        }
    </style>
</head>

<body>
    <ul class="box">
        <!-- <li class="active">
            <img src="./imgs/1.jpeg" alt="">
        </li>
        <li>
            <img src="./imgs/2.jpeg" alt="">
        </li>
        <li>
            <img src="./imgs/3.jpeg" alt="">
        </li>
        <li>
            <img src="./imgs/4.jpeg" alt="">
        </li>
        <li>
            <img src="./imgs/5.jpeg" alt="">
        </li> -->
    </ul>

    <script>
        let imgArr = ["./imgs/1.jpeg", "./imgs/2.jpeg", "./imgs/3.jpeg", "./imgs/4.jpeg", "./imgs/5.jpeg"];
        let box = document.getElementsByClassName("box")[0];
        let li = document.getElementsByTagName("li");

        for (let i = 0; i < imgArr.length; i++) {
            box.innerHTML += `
            <li>
                <img src="${imgArr[i]}" alt="">
            </li>
            `
        };
        li[0].classList.add("active");



        // 鼠标移入当前图片，当前图片宽度增大，其他图片宽度变小

        for (let i = 0; i < li.length; i++) {
            li[i].onmouseenter = function () {
                for (let j = 0; j < li.length; j++) {
                    li[j].classList.remove("active");
                }
                li[i].classList.add("active");
            }


        }
    </script>


</body>

</html>